package com.atlantis.apps.notifier.activity;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.widget.RatingBar;
import android.widget.RatingBar.OnRatingBarChangeListener;

import com.atlantis.apps.notifier.R;
import com.atlantis.apps.notifier.util.SNUtility;

public class SNAboutActivity extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.about);

		// Set the button functions
		RatingBar bar = (RatingBar) findViewById(R.id.ratingBar1);
		bar.setOnRatingBarChangeListener(saveRating);
	}

	private OnRatingBarChangeListener saveRating = new OnRatingBarChangeListener() {
		public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {

			if (SNUtility.sendRating(ratingBar.getContext(), String.valueOf(rating))) {
				AlertDialog alertDialog = new AlertDialog.Builder(ratingBar.getContext()).create();
				alertDialog.setTitle("Rated!");
				alertDialog.setMessage("Rated! Thanks :)");
				if (rating < 3.0)
					alertDialog.setIcon(R.drawable.stat_sad);
				else
					alertDialog.setIcon(R.drawable.stat_happy);
				alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						return;
					}
				});
				alertDialog.show();
				Log.d(getClass().getSimpleName(), "Rating shared for today");
			}
		}
	};
}